package leetcode.editor.vscdev.greedy;

public class lc53 {

}

class Solution {
    int res = Integer.MIN_VALUE;

    public int maxSubArray(int[] nums) {
        return res;
    }

    private void func1(int[] nums) {
        // 纯暴力, 测试用例不通过
        for (int i = 0; i < nums.length; i++) {
            int temp = 0;
            for (int j = i; j < nums.length; j++) {
                temp += j;
                if (temp>res) {
                    res = temp;
                }
            }
        }
    }
    private void func2(int[] nums){
        // 贪心, 局部最优转为全局最优
        int temp = 0;
        for (int i = 0; i < nums.length; i++) {
            temp += nums[i];
            if (temp < 0) {
                temp = 0;
                continue;
            }
            if (temp > res) {
                res = temp;
            }
        }
    }
    private void func3(int[] nums){
        // TODO 动态规划
        
    }
}